import request from '@/utils/request'

export function searchUser(name) {
  return request({
    url: '/vue-element-admin/search/user',
    method: 'get',
    params: { name }
  })
}

export function transactionList(query) {
  return request({
    url: '/vue-element-admin/transaction/list',
    method: 'get',
    params: query
  })
}

export function queryFileDir(sub_dir) {
  return request({
    url: '/view_files/scan/' + sub_dir,
    method: 'get'
  })
}

export function downloadFile(file_url, file_name) {
  window.open('/view_files/download/' + file_url)
}

export function getCurrentDir(dir) {
  return request({
    url: '/view_files/current_dir/' + dir,
    method: 'get'
  })
}

export function delete_file_or_dir(dir) {
  return request({
    url: '/view_files/delete_file/' + dir,
    method: 'get'
  })
}

export function unzip_selected_file(file_path) {
  return request({
    url: '/view_files/unzip_file/' + file_path,
    method: 'get'
  })
}

export function query_insects_info() {
  return request({
    url: '/insects_api/get_detailed_insects_info/',
    method: 'get'
  })
}

export function query_recent_insects_info() {
  return request({
    url: '/insects_api/get_recent_insects_info/',
    method: 'get'
  })
}

export function query_base64_result(file_path) {
  return request({
    url: '/insects_api/visual_insects_count/' + file_path,
    method: 'get'
  })
}

export function query_task_progress(task_url) {
  return request({
    url: '' + task_url,
    method: 'get'
  })
}

export function query_image(image_url) {
  return request({
    url: '/view_files/get_base64_image/' + image_url,
    method: 'get'
  })
}

export function query_visual_history() {
  return request({
    url: '/insects_api/get_visual_history/',
    method: 'get'
  })
}

export function update_insects_info(current_dir) {
  return request({
    url: '/insects_api/update_insects_info/' + current_dir,
    method: 'get'
  })
}

// export function transactionList() {
//   return request({
//     url: '/mock_data/transaction.json',
//     method: 'get'
//   })
// }
